/**
 * 根据共同的配置修改或者直接自定义个性化的配置
 */

import {
  commonProtoConfig,
  defaultChartOptions,
} from '@/components/common/VisualizationComp/ChartConfig/common'
import { cloneDeep } from 'lodash'

const {
  titleConfig,
  tooltipConfig,
  xAxis,
  yAxis,
  themeColorAllConfig,
} = commonProtoConfig

const copyXAxis = cloneDeep(xAxis)
const copyYAxis = cloneDeep(yAxis)

copyXAxis[0].children.splice(
  2,
  0,
  // @ts-ignore
  {
    type: 'inputNumber',
    label: '最大边界',
    name: 'xAxisMax',
    defaultValue: '',
  },
  {
    type: 'inputNumber',
    label: '最小边界',
    name: 'xAxisMin',
    defaultValue: '',
  }
)

const labelConfig = [
  {
    type: 'switch-group',
    label: '数据标签',
    name: 'labelIsShow',
    defaultValue: false,
    children: [
      {
        type: 'simpleColumnSelect',
        label: '气泡字段',
        name: 'labelField',
        defaultValue: null,
      },
    ],
  },
]

const quarantConfig = [
  {
    type: 'switch-group',
    label: '象限分割',
    name: 'quadrantOn',
    defaultValue: false,
    children: [
      {
        type: 'inputNumber',
        label: 'x轴分割值',
        name: 'xBaseline',
        // @ts-ignore
        defaultValue: null,
      },
      {
        type: 'inputNumber',
        label: 'y轴分割值',
        name: 'yBaseline',
        // @ts-ignore
        defaultValue: null,
      },
      {
        type: 'input',
        label: '左上标题',
        name: 'quadrantLabelTL',
      },
      {
        type: 'input',
        label: '左下标题',
        name: 'quadrantLabelBL',
      },
      {
        type: 'input',
        label: '右上标题',
        name: 'quadrantLabelTR',
      },
      {
        type: 'input',
        label: '右下标题',
        name: 'quadrantLabelBR',
      },
    ],
  },
]
export const protoConfig = [
  {
    label: '',
    type: 'property',
    children: [
      ...titleConfig,
      ...copyXAxis,
      ...copyYAxis,
      ...quarantConfig,
      ...labelConfig,
      {
        type: 'simpleColumnSelect',
        label: '大小度量',
        name: 'sizeField',
        defaultValue: null,
        props: {
          filterColsType: 'number',
        },
      },
      {
        type: 'simpleColumnSelect',
        label: '颜色度量',
        name: 'colorField',
        defaultValue: null,
      },
      ...tooltipConfig,
      ...themeColorAllConfig,
    ],
  },
]
/**
 * 图表渲染的默认配置
 */
export const defaultOptions = {
  ...defaultChartOptions,
}
